import os

def file_filtering(dir, suffix={"content":"","status":0}, prefix={"content":"","status":0}):
    # dir：路径
    # suffix：筛选后缀，输入格式{"content":".jpg","status":0}，status 为0表示筛选前缀为content的文件，为1表示排除前缀为content的文件
    # prefix：筛选前缀，输入格式{"content":".jpg","status":0}，status 为0表示筛选后缀为content的文件，为1表示排除后缀为content的文件
    if suffix["status"] ==0 and prefix["status"] == 0:
        return sorted(
            [os.path.join(dir, fname)
            for fname in os.listdir(dir)
            if fname.endswith(suffix["content"]) and fname.startswith(prefix["content"])])
    
    elif suffix["status"] ==1 and prefix["status"] == 0:
        return sorted(
            [os.path.join(dir, fname)
            for fname in os.listdir(dir)
            if not fname.endswith(suffix["content"]) and fname.startswith(prefix["content"])])
    
    elif suffix["status"] ==0 and prefix["status"] == 1:
        return sorted(
            [os.path.join(dir, fname)
            for fname in os.listdir(dir)
            if fname.endswith(suffix["content"]) and not fname.startswith(prefix["content"])])
    
    elif suffix["status"] ==1 and prefix["status"] == 1:
        return sorted(
            [os.path.join(dir, fname)
            for fname in os.listdir(dir)
            if not fname.endswith(suffix["content"]) and not fname.startswith(prefix["content"])])
    

if __name__ == "__main__":
    print(file_filtering(".\\data",suffix={"content":".jpg","status":1},prefix={"content":"mnist","status":0}))

    